
package com.lpc.framework.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author jiangjinlong
 *
 */
public class LogUtil {

    private static final Logger ERROR_LOG = LoggerFactory.getLogger("error");

    private static final Logger ACCESS_LOG = LoggerFactory.getLogger("web-access");

    /**
     * 记录异常错误 格式 [exception]
     *
     * @param message
     * @param e
     */
    public static void logError(String message, Throwable e) {
        StringBuilder s = new StringBuilder();
        s.append(getBlock("exception"));
        s.append(getBlock(message));
        ERROR_LOG.error(s.toString(), e);
    }

    public static String getBlock(Object msg) {
        if (msg == null) {
            msg = "";
        }
        return "[" + msg.toString() + "]";
    }

    public static Logger getAccessLog() {
        return ACCESS_LOG;
    }

    public static Logger getErrorLog() {
        return ERROR_LOG;
    }

}
